/*
 *  $Id: DiabolicDragon.cs 1051 2010-05-18 22:10:41Z thenn.erannor $
 *  This file is a part of Ragima CCG.
 *  (C) 2008 Ragima development group.
 *
 *  Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Darkness.Creatures {
    public class DiabolicDragon: DemonCreatureCard {
        public DiabolicDragon(): base("001_d_c_diabolic_dragon") {
            Level = CompleteLevel.ReadyForTest;
            Element = ElementType.Darkness;
            Value = 100;
            Race = new ComplexRace("dracodemon", RaceManager.GetRace<Races.Demon>(), RaceManager.GetRace<Races.Dragon>());
            Damage = 7;
            Health = 10;
            AddManaCost(ElementType.Darkness, 10);
            PactValue = 6;
        }
        public override void SetNaturalAffects(ICollector<Affect> affects) {
            affects.Add(new Affects.FearAura(3));
            affects.Add<Affects.Brutal>();
        }

        public override void ExecutePact(Player owner) {
            DoDeath(owner);
            DoDeath(owner.Enemy);
        }

        private static void DoDeath(Player player) {
            foreach (Creature cr in player.GetCreatures())
                cr.AddAffect(new DiabolicDragonAffect(cr.Health));
        }

        private class DiabolicDragonAffect: SpellAffect<DiabolicDragon> {
            private Affect _death;

            public DiabolicDragonAffect(int health): base(true) {
                DefaultName = true;
                DefaultDescription = true;
                if (health > 1) health--;
                _death = new Affects.Death(health);
                Add(_death);
            }

            public override Languages.Phrase Description {
                get { return _death.Description; }
            }
            public override string DescriptionText {
                get { return _death.DescriptionText; }
            }

            public override bool Dispellable {
                get { return false; }
            }
        }
    }
}
